﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Drawing;
using BurningSphere.Simulator.Properties;
using Microsoft.DirectX.Direct3D;

namespace BurningSphere.Simulator
{
	/// <summary>
	/// Single point of laser rendering history
	/// Also handles the laser fade.
	/// </summary>
	public class LaserHistory
	{
		public float X;
		public float Y;
		public Color Colour;
		float ColourR;
		float ColourG;
		float ColourB;
		float ColourA;

		/// <summary>
		/// Ctor
		/// </summary>
		/// <param name="x"></param>
		/// <param name="y"></param>
		public LaserHistory(float x, float y, ColorValue initialColour)
		{
			this.X = x;
			this.Y = y;
			this.ColourR = initialColour.Red;
			this.ColourG = initialColour.Green;
			this.ColourB = initialColour.Blue;
			this.ColourA = 1.0f;

			this.Colour = Color.FromArgb(
				(int)(this.ColourA*255.0),
				(int)(this.ColourR*255.0),
				(int)(this.ColourG*255.0),
				(int)(this.ColourB*255.0)
				
				);
		}

		/// <summary>
		/// Fade the laser colour
		/// </summary>
		public void Fade(ColorValue fadeScalar)
		{
			ColourA *= fadeScalar.Alpha;
			ColourR *= fadeScalar.Red;
			ColourG *= fadeScalar.Green;
			ColourB *= fadeScalar.Blue;

			this.Colour = Color.FromArgb(
				(int)(this.ColourA * 255.0),
				(int)(this.ColourR * 255.0),
				(int)(this.ColourG * 255.0),
				(int)(this.ColourB * 255.0)
				);

		}
	}
}
